package com.starryx.blog.dao;

import com.starryx.blog.po.Type;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;

import java.util.List;

public interface TypeRepository extends JpaRepository<Type, Long> {
    Type findByName(String name);

    // 用于前台首页展示，利用分页自带的排序，实现查询前几个的分类
    @Query("select t from Type t")
    List<Type> findTop(Pageable pageable);
}
